﻿using PeaceBlog.Helpers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Web;
using System.Web.Mvc;

namespace PeaceBlog.Controllers.Web.Blog
{
    public class BlogController : Controller
    {
        public BlogController()
        {

        }

        API.PostsController Posts = new API.PostsController();
        API.CategoriesController Categories = new API.CategoriesController();
        API.AuthorsController Authors = new API.AuthorsController();
        API.TagsController Tags = new API.TagsController();

        // GET: /
        public ActionResult AnaSayfa(int pageNumber = 1)
        {
            return View(Posts.GetPosts(1));
        }

        // GET: /Post/asp-net-mvc
        public async Task<ActionResult> Post(string Id)
        {
            if (string.IsNullOrEmpty(Id))
                return HttpNotFound();
            var post = await Posts.GetPost(Id);
            if (post == null)
                return HttpNotFound();
            return View(post);
        }

        // GET: /Kategori/asp-net
        public async Task<ActionResult> Kategori(int Id, int pageNumber = 1)
        {
            var category = await Categories.GetCategory(Id);
            if (category == null)
                return HttpNotFound();
            return View(category);
        }

        // GET: /Yazar/baris-ceviz
        public async Task<ActionResult> Yazar(string Id)
        {
            if (string.IsNullOrEmpty(Id))
                return HttpNotFound();
            var author = await Authors.GetAuthors(Id);
            if (author == null)
                return HttpNotFound();
            return View(author);
        }

        // GET: /Etiket/asp
        public async Task<ActionResult> Etiket(string Id)
        {
            if (string.IsNullOrEmpty(Id))
                return HttpNotFound();
            var tag = await Tags.GetTag(Id);
            if (tag == null)
                return HttpNotFound();
            return View(tag);
        }

        // GET: /Sitemap
        public ActionResult Rss()
        {
            return View();
        }
    }
}